$(document).ready(function(){
	//show loading bar
	function showLoader(){
		$('.search-background').fadeIn(200);
	}
	//hide loading bar
	function hideLoader(){
		$('.search-background').fadeOut(200);
	};
	
	$("#paging_button li").click(function(){
		//show the loading bar
		showLoader();
		
		$("#paging_button li").css({'background-color' : ''});

		$.ajax({
			url : base_url+ "notification/get_notifications/",
			type : 'post',
			data :
			{
				page : this.id,
			},
			dataType : 'json',
			success : function (response)
			{
				hideLoader();
				searchresults = response;
				DisplayPage();
			}
		})
	});
	
	// by default first time this will execute
	showLoader();
	$.ajax({
			url : base_url+ "notification/get_notifications/",
			type : 'post',
			data :
			{
				page : 1,
			},
			dataType : 'json',
			success : function (response)
			{
				hideLoader();
				searchresults = response;
				DisplayPage();
			}
		})
});

function DisplayPage()
{
	console.log(searchresults.length);
	var html = '';
	num = 0;
	
	for (var i = 0; i < 2; i++){
		var counter = i;
		
		if (typeof(searchresults[counter]) == "undefined"){
			if(html == ''){
				html += '<br />No notifications!';
			}
			break;
		}
		
		
		html += searchresults[counter].message;
	}
	$("#items-grid").html(html);
	$(".resize-150").load(function(){
			resize($(this), 150);
		});
}